/*Author Rajith Chathunga,
 *		 Computer Science and Engineering,
 *		 University of Moratuwa.
 *
 * Class name : FootblNews
 * 
 *  			
 * This class store football countries and their football rss URLs and send them to the QNews class. 
 * This class extends Activity and implements onClickListener.*/

package chathunga.qNews;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class FootblNews extends Activity implements OnClickListener {
	ListView lv1;
	NewsObjects no;
	String ss,t1,u1;
	TextView optn;
	ImageView img;
	Bundle b = new Bundle();
	private ArrayList<Object> ftnews=new ArrayList<Object>();
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.footblnews); 
        lv1=(ListView)findViewById(R.id.footcon);
        optn=(TextView)findViewById(R.id.addn);
        img=(ImageView)findViewById(R.id.qn);
        img.setOnClickListener(this);
        optn.setOnClickListener(this);
        data();
        
        lv1.setAdapter(new ArrayAdapter<Object>(this,R.layout.list_black_text,R.id.list_content , ftnews));
        lv1.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
            Toast.makeText(getBaseContext(), ""+ftnews.get(arg2), Toast.LENGTH_LONG).show();
            
            no=(NewsObjects) ftnews.get(arg2);
            ss=no.toStr();
            operation();
            
    	}
            });
        
        
        
	}
	//This method contains football countries and rss URLs in an ArrayList
	public void data(){
		
		ftnews.add(new NewsObjects("International","http://www.skysports.com/rss/0,20514,12010,00.xml"));
        ftnews.add(new NewsObjects("Spain","http://newsrss.bbc.co.uk/rss/sportonline_world_edition/football/rss.xml"));
        ftnews.add(new NewsObjects("Netherlands","http://netherlands.worldcupblog.org/feed"));
        ftnews.add(new NewsObjects("Germany","http://www.sportinglife.com/rss/football.xml"));
        ftnews.add(new NewsObjects("Brazil","http://www.sportinglife.com/rss/football.xml"));
        ftnews.add(new NewsObjects("Argentina","http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml"));
        ftnews.add(new NewsObjects("England","http://newsrss.bbc.co.uk/rss/sportonline_world_edition/football/rss.xml"));
        ftnews.add(new NewsObjects("Uruguay","http://www.skysports.com/rss/0,20514,11095,00.xml"));
        ftnews.add(new NewsObjects("Portugal","http://uk.eurosport.yahoo.com/football/portugal/index.html.xml"));
        ftnews.add(new NewsObjects("Croatia","http://croatia.worldcupblog.org/feed"));
        ftnews.add(new NewsObjects("Greece","http://greece.worldcupblog.org/feed"));
        ftnews.add(new NewsObjects("Norway","http://www.nordicfootball.info/category/norway/feed/"));
        
	}
	//This method is called when click on a cricket country.
	public void operation(){
		
		Intent it= new Intent(this,QNews.class);	

		b.putString("key", ss);

		it.putExtras(b);

		startActivity(it);
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v.getId()==R.id.addn){
			
			Intent it= new Intent(this,Option.class);
			
			startActivity(it);
			
		}
		if(v.getId()==R.id.qn){
			
			this.finish();
			
			Intent bToHome= new Intent(this,MainQNews.class);
			
			startActivity(bToHome);
			
			finish();
		}
		
		}
	}


